package lyl.hylanda;

import java.io.*;
import hylanda.dayooclient.DayooClient;

public class DayooClientTest {
	public FileWriter fw;
	public BufferedWriter bw;
	public Integer nTotalTime;
	public Integer nTotalLen;
	public Integer nTotalCnt;

	private DayooClient m_DayooClient;

	public static void main(String arg[]) {
		DayooClientTest test = new DayooClientTest();
		String text = "中华人民共和国中央军事委员会主席胡锦涛６月１４日签署通令，给邱光华同志追记一等功。成都军区某陆航团副师职飞行员邱光华同志，１９５７年４月出生，１９７４年４月入伍，１９７６年６月入党，大校军衔。入伍３４年来，邱光华同志忠诚使命，恪尽职守，长期坚守在飞行第一线，出色完成了开辟川藏青藏航线、国防科研试验、抢险救灾等重大任务，先后荣立二等功２次、三等功４次。成都军区日前给李月、王怀远、陈林、张鹏等遇难机组其他４名同志也追记一等功。";
		String cmd = "charset=utf-8;abs=1;keyword=1;class=1;AbsLen=100;kwdcnt=10";
		String result = test.test(text, cmd);
		System.out.println("result=\n" + result);
	}

	public String test(String text, String cmd) {
		try {
			m_DayooClient = new DayooClient();
			System.out.println("大洋网客户端java接口测试\n");

			// 连接服务器ip
			String szIp = "127.0.0.1";
			// 连接服务器port
			String szPort = "9981";
			int nPort = Integer.parseInt(szPort);

			// 创建连接对象
			int nConnRet = m_DayooClient.HLDayooConnect(szIp, nPort);

			if (nConnRet == 0) {
				System.out.print("Connect with server error!");
				return "";
			}
			String szTextResult = m_DayooClient.HLDayooAnalyzeAndGetResult(
					nConnRet, text, cmd);
			// 释放连接对象
			m_DayooClient.HLDayooDisconnect(nConnRet);
			return szTextResult;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "";
	}
}